/*
 * StartStopButtonListener.cpp
 *
 *  Created on: 27-12-2010
 *      Author: Przemek
 */

#include "listener/StartStopButtonListener.hpp"
#include "world/World.hpp"
using namespace std;

const string StartStopButtonListener::STOPPED_TEXT = "Start";
const string StartStopButtonListener::STARTED_TEXT = "Stop";

StartStopButtonListener::StartStopButtonListener(Button* button) :
	running(false), button(button)
{
	updateCaption();
}

void StartStopButtonListener::mouseReleased(const MouseListener::EventArguments&)
{
	running = !running;
	World::getInstance().setRunning(running);
	updateCaption();
}

void StartStopButtonListener::updateCaption()
{
	if(running)
	{
		button->setText(STARTED_TEXT);
	}
	else
	{
		button->setText(STOPPED_TEXT);
	}
}
